package com.chmingx.JavaBasic.thread.sync;

/**
 * synchronized 同步锁
 */
public class Ticket {
    private int number = 30;

    public synchronized void sale() {
        if (number > 0) {
            number--;
            System.out.println(Thread.currentThread().getName() + " 卖出一张票, 还剩下： " + number);
        }
    }
}
